unit uCadImp;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, FMTBcd, DB, DBClient, Provider, SqlExpr, Grids, DBGrids,
  JvExDBGrids, JvDBGrid, StdCtrls, Buttons, ExtCtrls, MMJPanel, ComCtrls,
  Mask, DBCtrls;

type
  TfcadImp = class(TForm)
    pgc1: TPageControl;
    ts1: TTabSheet;
    sImp: TSQLDataSet;
    dImp: TDataSetProvider;
    dsImp: TClientDataSet;
    dsImpID_IMPOSTO: TIntegerField;
    dsImpDESCRICAO: TStringField;
    dsImpPRAZO: TIntegerField;
    dsImpFERIADO: TIntegerField;
    dsImpDEDUCAO: TFloatField;
    dsImpVALOR_RETENCAO: TFloatField;
    dsImpMES: TIntegerField;
    dsImpANO: TIntegerField;
    dsrcImp: TDataSource;
    ds4: TDataSource;
    dsImpFilho: TClientDataSet;
    dImpFilho: TDataSetProvider;
    sImpFilho: TSQLDataSet;
    dsImpFilhoID_IMPFILHO: TIntegerField;
    dsImpFilhoID_IMPOSTO: TIntegerField;
    dsImpFilhoFAIXA: TIntegerField;
    dsImpFilhoVALOR_BASE: TFloatField;
    dsImpFilhoALIQUOTA: TFloatField;
    dsImpFilhoDEDUCAO: TFloatField;
    sImpFilhoID_IMPFILHO: TIntegerField;
    sImpFilhoID_IMPOSTO: TIntegerField;
    sImpFilhoFAIXA: TIntegerField;
    sImpFilhoVALOR_BASE: TFloatField;
    sImpFilhoALIQUOTA: TFloatField;
    sImpFilhoDEDUCAO: TFloatField;
    grp1: TGroupBox;
    lbl1: TLabel;
    edtRef: TEdit;
    grp2: TGroupBox;
    grp4: TGroupBox;
    grp5: TGroupBox;
    lbl2: TLabel;
    edtDeducao: TEdit;
    lbl3: TLabel;
    edtRetencao: TEdit;
    edtDiaPgto: TEdit;
    lbl4: TLabel;
    rgFer: TRadioGroup;
    JvDBGrid1: TJvDBGrid;
    sImpID_IMPOSTO: TIntegerField;
    sImpDESCRICAO: TStringField;
    sImpPRAZO: TIntegerField;
    sImpFERIADO: TIntegerField;
    sImpDEDUCAO: TFloatField;
    sImpVALOR_RETENCAO: TFloatField;
    sImpMES: TIntegerField;
    sImpANO: TIntegerField;
    sImpANO_MES: TStringField;
    dsImpANO_MES: TStringField;
    procedure FormShow(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  fcadImp: TfcadImp;
  vImposto : Integer;

implementation

uses UDM;

{$R *.dfm}

procedure TfcadImp.FormShow(Sender: TObject);
begin
  if (dsImp.Active) then
      dsImp.Close;
  dsImp.Params[0].AsInteger := vImposto;
  dsImp.Open;

  if (dsImpFilho.Active) then
      dsImpFilho.Close;
  dsImpFilho.Params[0].AsInteger := vImposto;
  dsImpFilho.Open;
  edtRef.Text := dsImpANO_MES.AsString;
  edtDiaPgto.Text := IntToStr(dsImpPRAZO.AsInteger);
  if (dsImpFERIADO.AsInteger = 0) then
    rgFer.ItemIndex := 0;
  if (dsImpFERIADO.AsInteger = 1) then
    rgFer.ItemIndex := 1;
  if (dsImpFERIADO.AsInteger = 2) then
    rgFer.ItemIndex := 2;
  edtDeducao.Text := FloatToStr(dsImpDEDUCAO.AsFloat);
  edtRetencao.Text := FloatToStr(dsImpVALOR_RETENCAO.AsFloat);  
end;

end.
